26. Araxis Merge File Comparison Report

Produced by Araxis Merge on 2021-05-13 09:08:39 +0000. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

26.1 Files compared

#LocationFileLast Modified
1/Applications/Ampps/www/Porto 3.2.2/Theme Files/Magento 2.x/Porto Theme/app/code/Mageplaza/LayeredNavigation/Model/LayerFilter.php2020-06-26 11:11:14 +0000
2/Applications/Ampps/www/Porto v4.0.0/Theme Files/Magento 2.x/Porto Theme/app/code/Mageplaza/LayeredNavigation/Model/LayerFilter.php2020-06-26 11:11:14 +0000

26.2 Comparison summary

DescriptionBetween
Files 1 and 2
Text BlocksLines
Unchanged1406
Changed00
Inserted00
Removed00

26.3 Comparison options

WhitespaceConsecutive whitespace is treated as a single space
Character caseDifferences in character case are significant
Line endingsDifferences in line endings (CR and LF characters) are ignored
CR/LF charactersNot shown in the comparison detail
Active line-pairing rules

26.4 Active regular expressions

No regular expressions were active.

26.5 Comparison detail

1 <?php 1 <?php
2 /** 2 /**
3  * Mageplaza 3  * Mageplaza
4  * 4  *
5  * NOTICE OF LICENSE 5  * NOTICE OF LICENSE
6  * 6  *
7  * This source file is subject to the Mageplaza.com license that is 7  * This source file is subject to the Mageplaza.com license that is
8  * available through the world-wide-web at this URL: 8  * available through the world-wide-web at this URL:
9  * https://www.mageplaza.com/LICENSE.txt 9  * https://www.mageplaza.com/LICENSE.txt
10  * 10  *
11  * DISCLAIMER 11  * DISCLAIMER
12  * 12  *
13  * Do not edit or add to this file if you wish to upgrade this extension to newer 13  * Do not edit or add to this file if you wish to upgrade this extension to newer
14  * version in the future. 14  * version in the future.
15  * 15  *
16  * @category    Mageplaza 16  * @category    Mageplaza
17  * @package     Mageplaza_LayeredNavigation 17  * @package     Mageplaza_LayeredNavigation
18  * @copyright   Copyright (c) Mageplaza (https://www.mageplaza.com/) 18  * @copyright   Copyright (c) Mageplaza (https://www.mageplaza.com/)
19  * @license     https://www.mageplaza.com/LICENSE.txt 19  * @license     https://www.mageplaza.com/LICENSE.txt
20  */ 20  */
21  21 
22 namespace Mageplaza\LayeredNavigation\Model\Layer; 22 namespace Mageplaza\LayeredNavigation\Model\Layer;
23  23 
24 use Magento\Catalog\Model\Layer\Filter\AbstractFilter; 24 use Magento\Catalog\Model\Layer\Filter\AbstractFilter;
25 use Magento\Catalog\Model\Layer\Filter\Item; 25 use Magento\Catalog\Model\Layer\Filter\Item;
26 use Magento\Framework\App\RequestInterface; 26 use Magento\Framework\App\RequestInterface;
27 use Magento\Framework\Exception\LocalizedException; 27 use Magento\Framework\Exception\LocalizedException;
28 use Mageplaza\LayeredNavigation\Helper\Data as LayerHelper; 28 use Mageplaza\LayeredNavigation\Helper\Data as LayerHelper;
29  29 
30 /** 30 /**
31  * Class Filter 31  * Class Filter
32  * @package Mageplaza\LayeredNavigation\Model\Layer 32  * @package Mageplaza\LayeredNavigation\Model\Layer
33  */ 33  */
34 class Filter 34 class Filter
35 { 35 {
36     /** @var RequestInterface */ 36     /** @var RequestInterface */
37     protected $request; 37     protected $request;
38  38 
39     /** @var array Slider types */ 39     /** @var array Slider types */
40     protected $sliderTypes = [LayerHelper::FILTER_TYPE_SLIDER]; 40     protected $sliderTypes = [LayerHelper::FILTER_TYPE_SLIDER];
41  41 
42     /** 42     /**
43      * Filter constructor. 43      * Filter constructor.
44      * 44      *
45      * @param RequestInterface $request 45      * @param RequestInterface $request
46      */ 46      */
47     public function __construct(RequestInterface $request) 47     public function __construct(RequestInterface $request)
48     { 48     {
49         $this->request = $request; 49         $this->request = $request;
50     } 50     }
51  51 
52     /** 52     /**
53      * Layered configuration for js widget 53      * Layered configuration for js widget
54      * 54      *
55      * @param AbstractFilter $filters 55      * @param AbstractFilter $filters
56      * @param $config 56      * @param $config
57      * 57      *
58      * @return mixed 58      * @return mixed
59      */ 59      */
60     public function getLayerConfiguration($filters, $config) 60     public function getLayerConfiguration($filters, $config)
61     { 61     {
62         $slider = []; 62         $slider = [];
63         foreach ($filters as $filter) { 63         foreach ($filters as $filter) {
64             if ($this->isSliderTypes($filter) && $filter->getItemsCount()) { 64             if ($this->isSliderTypes($filter) && $filter->getItemsCount()) {
65                 $slider[$filter->getRequestVar()] = $filter->getSliderConfig(); 65                 $slider[$filter->getRequestVar()] = $filter->getSliderConfig();
66             } 66             }
67         } 67         }
68         $config->setData('slider', $slider); 68         $config->setData('slider', $slider);
69  69 
70         return $this; 70         return $this;
71     } 71     }
72  72 
73     /** 73     /**
74      * @param $filter 74      * @param $filter
75      * @param null $types 75      * @param null $types
76      * 76      *
77      * @return bool 77      * @return bool
78      */ 78      */
79     public function isSliderTypes($filter, $types = null) 79     public function isSliderTypes($filter, $types = null)
80     { 80     {
81         $filterType = $this->getFilterType($filter); 81         $filterType = $this->getFilterType($filter);
82         $types      = $types ?: $this->sliderTypes; 82         $types      = $types ?: $this->sliderTypes;
83  83 
84         return in_array($filterType, $types, true); 84         return in_array($filterType, $types, true);
85     } 85     }
86  86 
87     /** 87     /**
88      * @param AbstractFilter $filter 88      * @param AbstractFilter $filter
89      * @param null $compareType 89      * @param null $compareType
90      * 90      *
91      * @return bool|string 91      * @return bool|string
92      */ 92      */
93     public function getFilterType($filter, $compareType = null) 93     public function getFilterType($filter, $compareType = null)
94     { 94     {
95         $type = LayerHelper::FILTER_TYPE_LIST; 95         $type = LayerHelper::FILTER_TYPE_LIST;
96         if ($filter->getRequestVar() === 'price') { 96         if ($filter->getRequestVar() === 'price') {
97             $type = LayerHelper::FILTER_TYPE_SLIDER; 97             $type = LayerHelper::FILTER_TYPE_SLIDER;
98         } 98         }
99  99 
100         return $compareType ? ($type === $compareType) : $type; 100         return $compareType ? ($type === $compareType) : $type;
101     } 101     }
102  102 
103     /** 103     /**
104      * Get option url. If it has been filtered, return removed url. Else return filter url 104      * Get option url. If it has been filtered, return removed url. Else return filter url
105      * 105      *
106      * @param Item $item 106      * @param Item $item
107      * 107      *
108      * @return mixed 108      * @return mixed
109      */ 109      */
110     public function getItemUrl($item) 110     public function getItemUrl($item)
111     { 111     {
112         if ($this->isSelected($item)) { 112         if ($this->isSelected($item)) {
113             return $item->getRemoveUrl(); 113             return $item->getRemoveUrl();
114         } 114         }
115  115 
116         return $item->getUrl(); 116         return $item->getUrl();
117     } 117     }
118  118 
119     /** 119     /**
120      * Check if option is selected or not 120      * Check if option is selected or not
121      * 121      *
122      * @param Item $item 122      * @param Item $item
123      * 123      *
124      * @return bool 124      * @return bool
125      * @throws LocalizedException 125      * @throws LocalizedException
126      */ 126      */
127     public function isSelected(Item $item) 127     public function isSelected(Item $item)
128     { 128     {
129         $filterValue = $this->getFilterValue($item->getFilter()); 129         $filterValue = $this->getFilterValue($item->getFilter());
130  130 
131         return !empty($filterValue) && in_array((string) $item->getValue(), $filterValue, true); 131         return !empty($filterValue) && in_array((string) $item->getValue(), $filterValue, true);
132     } 132     }
133  133 
134     /** 134     /**
135      * @param AbstractFilter $filter 135      * @param AbstractFilter $filter
136      * @param bool|true $explode 136      * @param bool|true $explode
137      * 137      *
138      * @return array|mixed 138      * @return array|mixed
139      */ 139      */
140     public function getFilterValue($filter, $explode = true) 140     public function getFilterValue($filter, $explode = true)
141     { 141     {
142         $filterValue = $this->request->getParam($filter->getRequestVar()); 142         $filterValue = $this->request->getParam($filter->getRequestVar());
143         if (empty($filterValue)) { 143         if (empty($filterValue)) {
144             return []; 144             return [];
145         } 145         }
146  146 
147         return $explode ? explode(',', $filterValue) : [$filterValue]; 147         return $explode ? explode(',', $filterValue) : [$filterValue];
148     } 148     }
149  149 
150     /** 150     /**
151      * Allow to show counter after options 151      * Allow to show counter after options
152      * 152      *
153      * @param AbstractFilter $filter 153      * @param AbstractFilter $filter
154      * 154      *
155      * @return bool 155      * @return bool
156      */ 156      */
157     public function isShowCounter($filter) 157     public function isShowCounter($filter)
158     { 158     {
159         return true; 159         return true;
160     } 160     }
161  161 
162     /** 162     /**
163      * Allow multiple filter 163      * Allow multiple filter
164      * 164      *
165      * @param AbstractFilter $filter 165      * @param AbstractFilter $filter
166      * 166      *
167      * @return bool 167      * @return bool
168      */ 168      */
169     public function isMultiple($filter) 169     public function isMultiple($filter)
170     { 170     {
171         return !($this->isSliderTypes($filter) || $filter->getRequestVar() === 'price'); 171         return !($this->isSliderTypes($filter) || $filter->getRequestVar() === 'price');
172     } 172     }
173  173 
174     /** 174     /**
175      * Checks whether the option reduces the number of results 175      * Checks whether the option reduces the number of results
176      * 176      *
177      * @param AbstractFilter $filter 177      * @param AbstractFilter $filter
178      * @param int $optionCount Count of search results with this option 178      * @param int $optionCount Count of search results with this option
179      * @param int $totalSize Current search results count 179      * @param int $totalSize Current search results count
180      * 180      *
181      * @return bool 181      * @return bool
182      */ 182      */
183     public function isOptionReducesResults($filter, $optionCount, $totalSize) 183     public function isOptionReducesResults($filter, $optionCount, $totalSize)
184     { 184     {
185         $result = $optionCount <= $totalSize; 185         $result = $optionCount <= $totalSize;
186  186 
187         if ($this->isShowZero($filter)) { 187         if ($this->isShowZero($filter)) {
188             return $result; 188             return $result;
189         } 189         }
190  190 
191         return $optionCount && $result; 191         return $optionCount && $result;
192     } 192     }
193  193 
194     /** 194     /**
195      * @param AbstractFilter $filter 195      * @param AbstractFilter $filter
196      * 196      *
197      * @return bool 197      * @return bool
198      */ 198      */
199     public function isShowZero($filter) 199     public function isShowZero($filter)
200     { 200     {
201         return false; 201         return false;
202     } 202     }
203 } 203 }